/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"0DD04019-E758-4C85-88BC-72229955CCFF"}
 */
function autoriza(event) {
	globals.gdeposito_ind = entrega_lugar
	var $cant = oc_cabecera_to_oc_detalle_ind.getSize()
	for (var i = 1 ; i <= $cant ; i++)
	{
		var $detalle = oc_cabecera_to_oc_detalle_ind.getRecord(i)
		
		$detalle.oc_detalle_to_productos_ind.stock_pend_recepcion += $detalle.cantidad
		$detalle.oc_detalle_to_productos_ind.productos_to_existencias_x_dep_ind.exi_pend_recepcion += $detalle.cantidad
	}
	oc_estado = 3
	filtrar()
}

/**
 * @properties={typeid:24,uuid:"E4139DC5-DB2B-4A48-9520-33641D94024E"}
 * @AllowToRunInFind
 */
function filtrar()
{
	controller.find()
	oc_estado = 1
	controller.search()
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"45C28559-8A1A-432A-B9DB-593A5DBD88B3"}
 */
function iraDtl(event) {
	forms.oc_cabecera_dtl_dlg_ind.controller.loadRecords(forms.oc_cabecera_autoriza_ind.oc_cabecera_id)
	var $win = application.createWindow('OC',JSWindow.MODAL_DIALOG)
	$win.title = 'Orden de Compra Nº '+forms.oc_cabecera_dtl_dlg_ind.nro_oc
	forms.oc_cabecera_dtl_dlg_ind.controller.show($win)
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"43965B67-6ABE-49E1-BF03-237270678D76"}
 */
function onShow(firstShow, event) {
	databaseManager.revertEditedRecords()
	databaseManager.setAutoSave(true)
	filtrar();
}
